import { useCallback, useMemo, useState } from "react";
import UseMemoSon from "./UseMemoSon";

import { useSelector } from "react-redux";



export default function UseMemoDemo() {

    let token=useSelector((state:any)=>state.token)

    const [count, setCount] = useState(0);
    const [title, setTitle] = useState("hello");

    console.log("aaaaaaaaaaaaa");

    const handleClick = useCallback(() => {
        console.log("点击了", new Date());
    }, [])


    // const handleClick=()=>{

    //     console.log("点击了",new Date());


    // }



    return (
        <div>

            {token}

            <button onClick={() => handleClick()}>useCallBack</button>

            <div>
                {title}
                <button onClick={() => setTitle("你好")}>修改</button>
            </div>
            {count}

            <button onClick={() => setCount(count + 1)}>修改</button>

            {
                useMemo(() => <UseMemoSon></UseMemoSon>, [title])
            }


        </div>
    )
}